package org.infodavid.common.lang;

import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.Date;

/**
 * The Class SerializerContext.
 * @param <T>
 */
public class SerializerContext<T extends Serializable> implements Serializable {

	/** serialVersionUID. */
	private static final long serialVersionUID = -8433183863360736426L;

	/** Default Encoding. */
	public static final Charset DEFAULT_ENCODING = Charset.forName("UTF-8");

	/** comment. */
	private String comment = null;

	/** author. */
	private String author = null;

	/** version. */
	private String version = null;

	/** date. */
	private Date date = null;

	/** data. */
	private T data = null;

	/**
	 * The Constructor.
	 */
	public SerializerContext() {
		super();
	}

	/**
	 * The Constructor.
	 * @param object the object
	 */
	public SerializerContext(final T object) {
		super();

		setData(object);
	}

	/**
	 * Gets the comment.
	 * @return the comment
	 */
	public String getComment() {
		return comment;
	}

	/**
	 * Sets the comment.
	 * @param value the comment to set
	 */
	public void setComment(final String value) {
		comment = value;
	}

	/**
	 * Gets the author.
	 * @return the author
	 */
	public String getAuthor() {
		return author;
	}

	/**
	 * Sets the author.
	 * @param value the author to set
	 */
	public void setAuthor(final String value) {
		author = value;
	}

	/**
	 * Gets the version.
	 * @return the version
	 */
	public String getVersion() {
		return version;
	}

	/**
	 * Sets the version.
	 * @param value the version to set
	 */
	public void setVersion(final String value) {
		version = value;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		final StringBuffer buffer = new StringBuffer(super.toString());

		buffer.append("[");
		buffer.append("author = ").append(author);
		buffer.append(" comment = ").append(comment);
		buffer.append(" version = ").append(version);
		buffer.append(" date = ").append(date);
		buffer.append(" data = ").append(data);
		buffer.append("]");

		return buffer.toString();
	}

	/**
	 * Gets the data.
	 * @return the data
	 */
	public T getData() {
		return data;
	}

	/**
	 * Sets the data.
	 * @param value the data to set
	 */
	public void setData(final T value) {
		data = value;
	}

	/**
	 * Gets the date.
	 * @return the date
	 */
	protected Date getDate() {
		return date;
	}

	/**
	 * Sets the date.
	 * @param value the date to set
	 */
	protected void setDate(final Date value) {
		date = value;
	}
}
